module LaboursHelper

  def display(labours)
    out = ""
    labours.each do |key, value|
      out += "-" + key.to_s + "<br>"
      if (value != nil and value.class == Hash)
        value.each do |key2, value2|
            if (value2 != nil and value2.class == Hash)
            out += "--"+ key2 + "<br>"
            value2.each do |key3, value3|
              out += "----"+ key3.to_s + "<br>"
              
              if (value3 != nil and value3.class == Hash)
                value3.each do |key4, value4|
                  out += "-----"+ key4.to_s + "::: "+ value4.to_s + "<br>"
                end
              else
                out += "----"+ key3.to_s + ": "+ value3.to_s + "<br>"
              end
            end
          else
            out += "--"+ key2.to_s + ": "+ value2.to_s + "<br>"
          end
        end
      end
    end
    out
  end

  def rates(labour)
    s=0
    labour.plinks.each do |plink| 
      s += plink.rate
    end
    s
  end
  
end
